﻿using Simple.Tools;
using Simple.Tools.SnowFlake;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleSaas.Common.DataBase
/// <summary>
/// 版 本 钢易智企2.0 V 2.0.0 钢易智企2.0
/// Copyright (c) 2023 杭州钢易科技有限公司
/// 创建人：曾东明
/// 日 期：2024
/// 描 述：
/// </summary>
{
	public class ComplexEntity<TKey>:BaseEntity<TKey>
	{
		private bool isDeleted;

		private long concurrencyStamp;

		private DateTime creationTime;

		private DateTime deletionTime;

		private long creatorID;

		private DateTime lastModificationTime;

		private long lastModifierID;

		private long deleterID;

		//
		// 摘要:
		//     修改标记--防止并发冲突
		[SugarColumn(ColumnName = "concurrency_stamp")]
		public long ConcurrencyStamp
		{
			get
			{
				return concurrencyStamp;
			}
			set
			{
				concurrencyStamp = value;
			}
		}

		//
		// 摘要:
		//     创建时间
		[SugarColumn(ColumnName = "creation_time")]
		public DateTime CreationTime
		{
			get
			{
				return creationTime;
			}
			set
			{
				creationTime = value;
			}
		}

		//
		// 摘要:
		//     创建者Id
		[SugarColumn(ColumnName = "creator_id")]
		public long CreatorID
		{
			get
			{
				return creatorID;
			}
			set
			{
				creatorID = value;
			}
		}

		//
		// 摘要:
		//     最后跟新时间
		[SugarColumn(ColumnName = "last_modification_time")]
		public DateTime LastModificationTime
		{
			get
			{
				return lastModificationTime;
			}
			set
			{
				lastModificationTime = value;
			}
		}

		//
		// 摘要:
		//     最后修改的id
		[SugarColumn(ColumnName = "last_modifier_id")]
		public long LastModifierID
		{
			get
			{
				return lastModifierID;
			}
			set
			{
				lastModifierID = value;
			}
		}

		//
		// 摘要:
		//     是否删除
		[SugarColumn(ColumnName = "is_deleted")]
		public bool IsDeleted
		{
			get
			{
				return isDeleted;
			}
			set
			{
				isDeleted = value;
			}
		}

		//
		// 摘要:
		//     删除者id
		[SugarColumn(ColumnName = "deleter_id")]
		public long DeleterID
		{
			get
			{
				return deleterID;
			}
			set
			{
				deleterID = value;
			}
		}

		//
		// 摘要:
		//     删除时间
		[SugarColumn(ColumnName = "deletion_time")]
		public DateTime DeletionTime
		{
			get
			{
				return deletionTime;
			}
			set
			{
				deletionTime = value;
			}
		}

		public ComplexEntity()
		{
		}

		//
		// 参数:
		//   Id:
		public void Update(long Id)
		{
			LastModificationTime = DateTime.Now;
			LastModifierID = Id;
			ConcurrencyStamp = Worker.Builder().NextId();
		}

		//
		// 参数:
		//   Id:
		public void Add(long Id)
		{
			LastModifierID = Id;
			LastModificationTime = DateTime.Now;
			CreationTime = DateTime.Now;
			CreatorID = Id;
			ConcurrencyStamp = Worker.Builder().NextId();
		}
	}
}
